<template>
	<view class="tab bgw">
		<view class="waitingItem" v-for="i in list" @click.stop="detail(i.id)">
			<!-- <img src="../static/bg/pyq.png" mode=""></img> -->
			<view class="patientInfoWrap">
				<view class="info">
					<view class="left_info">
						{{i.user.name}}
						<text v-if="i.user.sex == 1" class="sex">男</text>
						<text v-else class="sex">女</text>
						<text>{{i.user.nianling}}</text>
					</view>
					<!-- <view class="right_time">剩余09:54:08</view> -->
				</view>
				<view class="llness">病情描述：<text>{{i.miaoshu}}</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		zixun
	} from '../request/api.js'
	export default {
		name: "tab3",
		data() {
			return {
				// 上拉加载
				page: 1,
				pages: 0,
				list: []
			};
		},
		props:['refresh3'],
		watch: {
			refresh3(newValue, oldValue) {
				// console.log(newValue, oldValue)
				this.page++;
				if (this.page > this.pages) {
					uni.hideNavigationBarLoading();
					uni.showToast({
						title: '暂无更多数据',
						icon: 'none'
					})
				} else {
					this.getList(this.page);
				}
			}
		},
		mounted() {
			if(uni.getStorageSync('token')){
				this.getList(1)
			}
		},
		methods: {
			// 列表
			getList(page) {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				zixun({
					page: page,
					listRows: 20,
					status: 3
				}).then(res => {
					this.pages = res.totalPages;
					if (this.page == 1) {
						this.list = res.data;
						if (this.list.length === 0 || this.list.length === '0') {
							uni.showToast({
								icon: 'none',
								duration: 3000,
								title: '暂无数据'
							});
							return
						}
					} else {
						this.list = this.list.concat(res.data);
					}
					uni.hideLoading()
					uni.hideNavigationBarLoading()
				})
			},
			detail(id) {
				uni.navigateTo({
					url:'/pages/patientDetail/patientDetail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab {
		.waitingItem {
			padding: 30upx;

			img {
				width: 80upx;
				height: 80upx;
				margin-right: 28upx;
				flex-shrink: 0;
			}

			.patientInfoWrap {
				flex: 1;

				.info {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 16upx;

					.left_info {
						font-size: 28upx;
						font-family: Source Han Sans CN;
						font-weight: bold;
						color: #414141;

						text {
							font-weight: 200;
						}

						.sex {
							padding: 0 24upx;
							margin: 0 24upx;
							border-left: 2upx solid #CCCCCC;
							border-right: 2upx solid #CCCCCC;
						}
					}

					.right_time {
						font-size: 28upx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #BC9869;
					}
				}

				.time,
				.llness {
					font-size: 28upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #414141;
					margin-bottom: 16upx;
					display: flex;

					text {
						color: #7B7B7B;
						margin-left: 16upx;
						width: 520upx;
						display: block;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				.llness {
					margin-bottom: 32upx;
				}

				.receiveTreatment {
					width: 176upx;
					background: #FDF4F5;
					border: 2upx solid #F86C53;
					border-radius: 32upx;
					font-size: 28upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #F86C53;
					padding: 10upx 0;
					text-align: center;
				}
			}
		}
	}
</style>
